package com.k12.user.controller;

import com.k12.user.model.entity.SysAreaProvinces;
import com.k12.user.service.SysAreaProvincesService;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
/**
 * 省份代码库(SysAreaProvinces)表控制层
 *
 * @author makejava
 * @since 2025-07-28 20:53:10
 */
@RestController
@RequestMapping("sysAreaProvinces")
public class SysAreaProvincesController {
    /**
     * 服务对象
     */
    @Resource
    private SysAreaProvincesService sysAreaProvincesService;

    /**
     * 分页查询
     *
     * @param sysAreaProvinces 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping("getAllProvinces")
    public List<SysAreaProvinces> queryByPage(SysAreaProvinces sysAreaProvinces) {
        return this.sysAreaProvincesService.queryByPage(sysAreaProvinces);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("getOneProvinces/{id}")
    public SysAreaProvinces queryById(@PathVariable("id") Integer id) {
        return this.sysAreaProvincesService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param sysAreaProvinces 实体
     * @return 新增结果
     */
    @PostMapping("insertProvinces")
    public SysAreaProvinces add(SysAreaProvinces sysAreaProvinces) {
        return this.sysAreaProvincesService.insert(sysAreaProvinces);
    }

    /**
     * 编辑数据
     *
     * @param sysAreaProvinces 实体
     * @return 编辑结果
     */
    @PostMapping("updateProvinces")
    public SysAreaProvinces edit(SysAreaProvinces sysAreaProvinces) {
        return this.sysAreaProvincesService.update(sysAreaProvinces);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("deleteProvinces")
    public Boolean deleteById(Integer id) {
        return this.sysAreaProvincesService.deleteById(id);
    }

}

